<?php
class TempNotice{

    //给诊疗客户发等待反馈通知
    public static function zhenliaowaitnoticetouser($openid,$user,$data)
    {
        if(empty($user)=== FALSE && empty($user['name']) === FALSE) {
            $accessToken = \Tools::getaccessToken();
            $send_data = array(
                "thing3" => array(
                    "value" => $user['name'] ?? '未知'
                ),
                "thing5" => array(
                    "value" => $data['content']
                ),
                "thing2" => array(
                    "value" => '您的诊疗申请已提交，请关注平台消息。'
                )
            );

            $res = \Wxchat::sendtmpldetail($openid, 'rZMPQ_cuhcvMo6m8owotF1r-2kEBtOZlkR9p8vqXtUs', $accessToken, $send_data);
            return $res;
        }

    }
    //给诊疗客户发已反馈通知
    public static function zhenliaonoticetouser($openid,$data)
    {
        $accessToken = \Tools::getaccessToken();
        $send_data = array(
            "thing2" => array(
                "value" => '诊疗建议已有新的回复,请及时查看'
            ),
            "time4" => array(
                "value" => datetime(time(),'Y-m-d H:i:s')
            ),
            "thing3" => array(
                "value" => '请进入小程序查看详情。'
            )
        );
        return \Wxchat::sendtmpldetail($openid, 'y6mNzqVmBt2GYZ6DK3SGh0AmJdgS9YGpWc81iyCcgSQ', $accessToken, $send_data);
    }
    //诊疗客户提交给客服发通知通知
    public static function zhenliaowaitnoticetoadmin($data)
    {
       $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => '新的诊疗建议获取请求'
           ),
           "thing4" => array(
               "value" => '客户提交获取诊疗建议申请,请及时回复。'
           )
       );
       $user = \app\admin\model\vppz\User::where(['is_admin'=>1])->column('openid');
       if(empty($user)===FALSE){
           foreach ($user as &$v){
                $res = \Wxchat::sendtmpldetail($v, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);

           }
       }

    }
    //体检下单
    public static function tijiantoadmin($content){
        $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => '预约体检通知'
           ),
           "thing4" => array(
               "value" => $content
           )
       );
       $user = \app\admin\model\vppz\User::where(['is_admin'=>1])->column('openid');
       if(empty($user)===FALSE){
           foreach ($user as &$v){
                \Wxchat::sendtmpldetail($v, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
           }
       }
    }
    //开通家庭会员通知管理员
    public static function familyviptoadmin($content){
        $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => '家庭医生会员开通通知'
           ),
           "thing4" => array(
               "value" => $content
           )
       );
       $user = \app\admin\model\vppz\User::where(['is_admin'=>1])->column('openid');
       if(empty($user)===FALSE){
           foreach ($user as &$v){
                \Wxchat::sendtmpldetail($v, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
           }
       }
    }
    //器械租售通知管理员
    public static function qixiezushoutoadmin($content){
        $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => '器械租售新订单'
           ),
           "thing4" => array(
               "value" => $content
           )
       );
       $user = \app\admin\model\vppz\User::where(['is_admin'=>1])->column('openid');
       if(empty($user)===FALSE){
           foreach ($user as &$v){
                \Wxchat::sendtmpldetail($v, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
           }
       }
    }
    //康养模块新订单通知管理员有
    public static function kangyangtoadmin($content){
        $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => '居家康养套餐新订单'
           ),
           "thing4" => array(
               "value" => $content
           )
       );
       $user = \app\admin\model\vppz\User::where(['is_admin'=>1])->column('openid');
       if(empty($user)===FALSE){
           foreach ($user as &$v){
                \Wxchat::sendtmpldetail($v, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
           }
       }
    }
    //疫苗接种通知
    public static function yimiaojiezhong($openid,$name,$address,$content){
        $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "name8" => array(
               "value" => $name
           ),
           "thing4" => array(
               "value" => $address
           ),
           "thing7" => array(
               "value" => $content
           )
       );
       $res = \Wxchat::sendtmpldetail($openid, 'BGzUIeFJ3Hc4pN7_ODFKTz9IxvfAWYsPffIReTKB88s', $accessToken, $send_data);
       return $res;
    }
    //问诊提醒
    public static function wenzhentixing($title,$content,$openid){
       $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "thing2" => array(
               "value" => $title
           ),
           "thing4" => array(
               "value" => $content
           )
       );
       $res = \Wxchat::sendtmpldetail($openid, 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
       return $res;
    }
    //就诊提醒
    public static function jiuzhentixing($data){
       $accessToken = \Tools::getaccessToken();
       $send_data = array(
           "name1" => array(
               "value" => $data['name']
           ),
           "thing4" => array(
               "value" => $data['keshi']
           ),
           "thing8" => array(
               "value" => $data['hospital']
           ),
           "date5" => array(
               "value" => $data['date']
           ),
           "thing7" => array(
               "value" => $data['content']
           )
       );
       $res = \Wxchat::sendtmpldetail($data['openid'], 'kd_vCXBL7Xww9IUkdYCzAwcaiuUzScrjeXh-GGTvGsM', $accessToken, $send_data);
       return $res;
    }
}
